package com.ly.algorithm.offerpointer;

/**
 * @Classname Offer46
 * @Description TODO
 * @Date 2021/1/31 16:42
 * @Author 冷心影翼
 */
public class Offer46 {

    public static void main(String[] args) {
        Solution46 solution46 = new Solution46();
        System.out.println(solution46.translateNum(506));
    }
}


class Solution46 {
    public int translateNum(int num) {
        String s = num+"";
        if(s.length() == 0) {
            return 0;
        }
        int[] dp = new int[s.length()+1];
        dp[0] = 1;
        dp[1] = 1;
        for (int i = 1; i < s.length() ; i++) {
            if(s.charAt(i-1)>'2' || (s.charAt(i-1) == '2' && s.charAt(i)>'5') || s.charAt(i-1) == '0') {
                dp[i+1] = dp[i];
            }else {
                dp[i+1] = dp[i]+dp[i-1];
            }
        }
        return dp[s.length()];
    }
}